<?
//$pj_sess_save_path=dirname(__FILE__)."/sess/";
function pj_open($save_path, $session_name)
{
  return(true);
}

function pj_close()
{
  return(true);
}

function pj_read($id)
{
  global $pj_sess_save_path;

  $sess_file = "$pj_sess_save_path/sess_$id";
  return (string) @file_get_contents($sess_file);
}

function pj_write($id, $sess_data)
{
  global $pj_sess_save_path;

  $sess_file = "$pj_sess_save_path/sess_$id";
  if ($fp = @fopen($sess_file, "w")) {
    $return = fwrite($fp, $sess_data);
    fclose($fp);
    return $return;
  } else {
    return(false);
  }

}

function pj_destroy($id)
{
  global $pj_sess_save_path;

  $sess_file = "$pj_sess_save_path/sess_$id";
  return(@unlink($sess_file));
}

function pj_gc($maxlifetime)
{
  global $pj_sess_save_path;

  foreach (glob("$pj_sess_save_path/sess_*") as $filename) {
    if (filemtime($filename) + $maxlifetime < time()) {
      @unlink($filename);
    }
  }
  return true;
}

session_set_save_handler("pj_open", "pj_close", "pj_read", "pj_write", "pj_destroy", "pj_gc");

?>
